package com.voicechat.firstmet.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.util.Log;


/**
 * @author Android
 * 倒计时 工具类
 */

public class ContDownUtil extends CountDownTimer {
    Context context;
    private String TAG = "ContDownUtil";
    private GetTimeFinish getTimeFinish;

    public void setGetTimeFinish(GetTimeFinish getTimeFinish) {
        this.getTimeFinish = getTimeFinish;
    }

    public ContDownUtil(long countDownTime, Context context) {
        super(countDownTime * 1000, 1000);
        this.context = context;
    }

    public void myStart() {
        this.start();
    }


    @Override
    public void onTick(long millisUntilFinished) {
        getTimeFinish.onTick(millisUntilFinished / 1000);
    }

    @Override
    public void onFinish() {
        this.cancel();
        getTimeFinish.downFinish();
    }
    //时间结束回调
    public interface GetTimeFinish{
        void downFinish();
        void onTick(long millisUntilFinished);
    }

}
